package com.yksj.healthtalk.ui.buyandsell;

import java.util.ArrayList;
import java.util.List;

import org.handmark.pulltorefresh.library.PullToRefreshBase;
import org.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import org.handmark.pulltorefresh.library.PullToRefreshListView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.yksj.healthtalk.adapter.ShopListViewAdapter;
import com.yksj.healthtalk.comm.BaseFragmentActivity;
import com.yksj.healthtalk.entity.ShopListItemEntity;
import com.yksj.healthtalk.ui.R;
import com.yksj.healthtalk.ui.server.ServerCenterDescription;
import com.yksj.healthtalk.ui.setting.SettingWebUIActivity;

public class OriderDetailsActivity extends BaseFragmentActivity implements OnClickListener, OnRefreshListener<ListView>, OnItemClickListener {
	private PullToRefreshListView mPullToRefreshListView;
	private ListView mListView;
	private ShopListViewAdapter adapter;
	private List<ShopListItemEntity> entities=new ArrayList<ShopListItemEntity>();

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.orider_details_layout);
		initView();
	}
	
	private void initView(){
		initTitle();
		titleLeftBtn.setOnClickListener(this);
		titleTextV.setText("订单详情");
		
		adapter = new ShopListViewAdapter(this, entities);
		mPullToRefreshListView = (PullToRefreshListView)findViewById(R.id.hall);
		mListView = mPullToRefreshListView.getRefreshableView();
		mPullToRefreshListView.setOnRefreshListener(this);
		mListView.setDivider(getResources().getDrawable(R.drawable.list_divider_bg));
		mListView.setAdapter(adapter);
		mListView.setOnItemClickListener(this);
		findViewById(R.id.enter_orider_details).setOnClickListener(this);
		initData();
	}

	private void initData() {
		
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.title_back:
			onBackPressed();
			break;
		case R.id.enter_orider_details://进入药房网订单详情
			Intent intent=new Intent(this,SettingWebUIActivity.class);
			intent.putExtra("url", "http://www.baidu.com");
			intent.putExtra("title", "订单");
			startActivity(intent);
			break;
		}
	}

	@Override
	public void onRefresh(PullToRefreshBase<ListView> refreshView) {
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Intent intent=new Intent(this,ServerCenterDescription.class);
		ShopListItemEntity entity = entities.get(position-1);
		intent.putExtra("entity", entity);
		startActivity(intent);
	}

}
